package group.Filter;


import org.apache.log4j.Logger;

import javax.servlet.*;
import java.io.IOException;

/**
 * 过滤器在web启动完成就执行,属于serlvet
 */
public class TestFilter implements Filter {
    private Logger logger = Logger.getLogger(TestFilter.class);
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        logger.debug("Filter 初始化！！");
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        logger.debug("Filter 执行过滤器");
        //这里是让请求继续执行下去，不调用这个方法就只会执行到这里
        filterChain.doFilter(servletRequest,servletResponse);
    }

    @Override
    public void destroy() {
        logger.debug("Filter 销毁!!");
    }
}
